from flask import Flask,request
from flask import render_template
# 调用自定义模块中的函数
from reserch import reserch4letters

# Flask:中央登记中心
app = Flask(__name__)

# 【Flask】(https://dormousehole.readthedocs.io/en/latest/quickstart.html#id10)
# 【HTMl】(https://www.w3school.com.cn/html/index.asp)
# 【jinja2】(https://palletsprojects.com/p/jinja/)

# 网站首页
@app.route('/',methods=['GET'])
def hello_world():
    return render_template('hello.html')

#名字全称拼写
@app.route('/name',methods=['GET'])
def index():
    return render_template('name.html')

@app.route('/result_name',methods=['GET','POST'])
def result_name():
    py_firstname = request.form['firstname']
    py_lastname = request.form['lastname']
    py_fullname = py_firstname.title()+' '+py_lastname.title()
    return render_template('result_name.html',fullname=py_fullname)


###元音字母查询
@app.route('/word',methods=['GET','POST'])
def word():
    return render_template('word.html')

@app.route('/results_word',methods=['GET','POST'])
def results_word():
    py_word = request.form['word']
    py_vowels = request.form['vowels']
    py_found = reserch4letters(py_vowels, py_word)
    return render_template('results_word.html', found = py_found)

##购物车
@app.route('/carlist',methods=['GET','POST'])
def carlist():
    return render_template('carlist.html')

@app.route('/goods',methods=['GET','POST'])
def goods():
    return render_template('goods.html')

@app.route('/count',methods=['GET','POST'])
def count():
    return render_template('count.html')

@app.route('/end',methods=['GET','POST'])
def end():
    return render_template('end.html')


if __name__ == '__main__':
    app.run(host='127.0.0.1',port=5000,debug=True)
